﻿<p>
    This example shows the client-side events supported by Telerik Grid for ASP.NET MVC.
</p>
<p>
    The Grid has four events:
</p>
<ul>
    <li>
        The <em>OnLoad</em> event is raised when the component is initialized. You can subscribe to that event by using one of the two overloads of the <strong>OnLoad</strong> method. 
        The one accepts Action as an argument - the other accepts a String.
        Use the Action overload to define the event handler inline. Use the String overload
        to specify the name of the JavaScript function which handles the event. The following code shows both options:
<pre class="prettyprint">
&lt;%= Html.Telerik().Grid(Model)
        .Name("Grid")
        .ClientEvents(events => events
            <em>.OnLoad("onLoad")</em>
        )
</pre>
or
<pre class="prettyprint">
&lt;% Html.Telerik().Grid(Model)
       .Name("Grid")
       .ClientEvents(events => events
       <em>.OnLoad(() => 
       {
        %&gt;
         function(e) {
             //perform required actions here.
         }
        &lt;%
       })</em>
       .Render();
</pre>
    </li>
    <li>
        The <em>OnDataBinding</em> event is raised when the grid is requesting data. You can subscribe to that event by using one of the two overloads of the <strong>OnOpen</strong> method: 
<pre class="prettyprint">
&lt;%= Html.Telerik().Grid(Model)
        .Name("Grid")
        .ClientEvents(events => events
            <em>.OnDataBinding("onDataBinding")</em>
        )
</pre>
or
<pre class="prettyprint">
&lt;% Html.Telerik().Grid(Model)
       .Name("Grid")
       .ClientEvents(events => events
       <em>.OnDataBinding(() => 
       {
           %&gt;
            function(e) {
                //perform required actions here.
            }
           &lt;%
       })</em>
       .Render();
</pre>
    </li>
    <li>
        The <em>OnError</em> event is raised when an error occurs during data retrieval. You can subscribe to that event by using one of the two overloads of the <strong>OnClose</strong> method: 
<pre class="prettyprint">
&lt;%= Html.Telerik().Grid(Model)
        .Name("Grid")
        .ClientEvents(events => events
            <em>.OnError("onError")</em>
        )
</pre>
or
<pre class="prettyprint">
&lt;% Html.Telerik().Grid(Model)
       .Name("Grid")
       .ClientEvents(events => events
       <em>.OnError(() => 
       {
           %&gt;
            function(e) {
                //perform required actions here.
            }
           &lt;%
       })</em>
       .Render();
</pre>
    </li>
    <li>
        The <em>OnRowDataBound</em> event is raised when row in the grid is databound. You can subscribe to that event by using one of the two overloads of the <strong>OnSelect</strong> method: 
<pre class="prettyprint">
&lt;%= Html.Telerik().Grid(Model)
        .Name("Grid")
        .ClientEvents(events => events
            <em>.OnRowDataBound("onRowDataBound")</em>
        )
</pre>
or
<pre class="prettyprint">
&lt;% Html.Telerik().Grid(Model)
       .Name("Grid")
       .ClientEvents(events => events
       <em>.OnRowDataBound(() => 
       {
           %&gt;
            function(e) {
                //perform required actions here.
            }
           &lt;%
       })</em>
       .Render();
</pre>
    </li>
</ul>